﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SysRouteLinq.Forms
{
    public partial class EditParada : Form
    {
        private SysRouteDataContext dc;
        private int idParada;
        private Parada p;
        
        public EditParada(int aIdParada)
        {
            InitializeComponent();
            dc = new SysRouteDataContext();
            idParada = aIdParada;

            p = (from f in dc.Paradas
                 where
                 f.id_parada == idParada
                 select f).Single();

            textBox1.Text = p.nome;
            textBox2.Text = p.referencia;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            p.nome = textBox1.Text;
            p.referencia = textBox2.Text;
            dc.SubmitChanges();
            MessageBox.Show("Alteração realizada com sucesso!");
        }


        private void button2_Click(object sender, EventArgs e)
        {
        }
    }
}
